import request from '@/utils/request'

const apis = {
    LOGOIN: '/access/login',
    VALID_CODE: '/remoteapi/getverificationsms',
    REGISTRER: '/access/register',
    MODIFY_PASSWORD: '/access/modifypassword',
    FORGET_PASSWORD: '/access/forgetpassword',
    USER_INFO: '/user/getbaseinfo',
    MODIFY_BASE_INFO: '/user/modifybaseinfo',
    VALID_CODE_IMG: '/remoteapi/getverificationcode',
    MY_PROGRESS: '/personalcenter/getmyprogress',
    INFO_DETAIL: '/specific/getmobilepersonalcenter',
    My_NOTICE_LIST: '/personalcenter/getmynoticelist',
    FQA_DETAIL: '/personalcenter/getfaq',
    GET_PLAT_INFO: '/personalcenter/getintro',
    My_SUGGESTION_LIST: '/personalcenter/getmysuggestionlist',
    ADD_MY_SUGGESTION: '/personalcenter/addmysuggestion',
    COMPLETE_DATA: '/personalcenter/completedata',
    GET_MY_DATA: '/personalcenter/getmydata'
}

export default {
    
    // 登录
    login(data) {
        let dt = data || {};
        return request.post(apis.LOGOIN, dt.params, {
            headers: dt.headers || {}
        });
    },

    // 取手机验证码
    getValidCode(data) {
        let dt = data || {};
        return request.post(apis.VALID_CODE, dt.params, {
            headers: dt.headers || {}
        });
    },

    // 注册
    register(data) {
        let dt = data || {};
        return request.post(apis.REGISTRER, dt.params, {
            headers: dt.headers || {}
        });
    },

    // 修改密码
    modifyPassword(data) {
        let dt = data || {};
        return request.post(apis.MODIFY_PASSWORD, dt.params, {
            headers: dt.headers || {}
        });
    },

    // 忘记密码
    forgetPassword(data) {
        let dt = data || {};
        return request.post(apis.FORGET_PASSWORD, dt.params, {
            headers: dt.headers || {}
        });
    },

    // 获取基本信息
    getUserInfo(data) {
        let dt = data || {};
        return request.post(apis.USER_INFO, dt.params, {
            headers: dt.headers || {}
        });
    },
    
    modifyBaseInfo(data) {
        let dt = data || {};
        let params = dt.params || {};
        let formData = new FormData();
        for (let k in params) {
            if (k && params[k] != null) {
                formData.append(k + '', params[k]);
            }
        }

        return request.post(apis.MODIFY_BASE_INFO, formData, {
            headers: Object.assign({
                'Content-Type': 'multipart/form-data'
            }, dt.headers)
        });
    },

    modifyBaseInfo2(data) {
        let dt = data || {};
        return request.post(apis.MODIFY_BASE_INFO, dt.params, {
            headers: dt.headers || {}
        });
    },

    getValidCodeImg(data) {
        let dt = data || {};
        return request.post(apis.VALID_CODE_IMG, dt.params, {
            headers: dt.headers || {}
        });
    },

    getMyProgress(data) {
        let dt = data || {};
        return request.post(apis.MY_PROGRESS, dt.params, {
            headers: dt.headers || {}
        });
    },

    getInfoDetail(data) {
        let dt = data || {};
        return request.post(apis.INFO_DETAIL, dt.params, {
            headers: dt.headers || {}
        });
    },

    getMyNoticeList(data) {
        let dt = data || {};
        return request.post(apis.My_NOTICE_LIST, dt.params, {
            headers: dt.headers || {}
        });
    },

    getFQADetail(data) {
        let dt = data || {};
        return request.post(apis.FQA_DETAIL, dt.params, {
            headers: dt.headers || {}
        });
    },

    getPlatInfo(data) {
        let dt = data || {};
        return request.post(apis.GET_PLAT_INFO, dt.params, {
            headers: dt.headers || {}
        });
    },

    getMySuggestionList(data) {
        let dt = data || {};
        return request.post(apis.My_SUGGESTION_LIST, dt.params, {
            headers: dt.headers || {}
        });
    },

    addMySuggestion(data) {
        let dt = data || {};
        return request.post(apis.ADD_MY_SUGGESTION, dt.params, {
            headers: dt.headers || {}
        });
    },

    completeData(data) {
        let dt = data || {};
        return request.post(apis.COMPLETE_DATA, dt.params, {
            headers: dt.headers || {}
        });
    },

    getMyData(data) {
        let dt = data || {};
        return request.post(apis.GET_MY_DATA, dt.params, {
            headers: dt.headers || {}
        });
    }

}